Skip to main content
Glama
ZephyrDeng

mcp-server-gitlab

Gitlab Search User Projects Tool

Search user profiles and active projects on GitLab using a username. Filter API response fields to retrieve specific data efficiently.

Instructions

根据用户名搜索用户信息及其活跃项目。支持字段过滤,提升响应效率。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fieldsNo需要返回的字段路径数组,支持数组或逗号分隔字符串,用于过滤 API 响应字段。 示例: - ["id", "name", "owner.username"] - "id,name,owner.username" - undefined
usernameYes用户名

Implementation Reference

  • The main handler function implementing the tool logic: searches GitLab users by username, fetches their projects, applies optional field filtering, and returns JSON result or error message.
    async execute(args: unknown, context: Context<Record<string, unknown> | undefined>) {
      const typedArgs = args as {
        username: string;
        fields?: string[] | string;
      };
    
      try {
        const client = createGitlabClientFromContext(context);
        const users = await client.apiRequest("/users", "GET", { search: typedArgs.username });
        if (!Array.isArray(users) || users.length === 0) {
          return {
            content: [
              {
                type: "text",
                text: `未找到用户名为 ${typedArgs.username} 的用户`
              }
            ],
            isError: true
          };
        }
        
        const user = users[0];
        const projects = await client.apiRequest(`/users/${user.id}/projects`, "GET", {});
        const result = { user, projects };
    
        if (typedArgs.fields) {
          const fieldsArray = Array.isArray(typedArgs.fields)
            ? typedArgs.fields
            : typedArgs.fields.split(",").map(f => f.trim()).filter(f => f);
          const filteredResult = filterResponseFields(result, fieldsArray);
          return {
            content: [{ type: "text", text: JSON.stringify(filteredResult) }]
          } as ContentResult;
        } else {
          return {
            content: [{ type: "text", text: JSON.stringify(result) }]
          } as ContentResult;
        }
      } catch (error: any) {
        return {
          content: [
            {
              type: "text",
              text: `GitLab MCP 工具调用异常:${error?.message || String(error)}`
            }
          ],
          isError: true
        };
      }
    },
  • Tool metadata including name, description, and Zod input schema for 'username' (required string) and 'fields' (optional for filtering).
    name: "Gitlab Search User Projects Tool",
    description: "根据用户名搜索用户信息及其活跃项目。支持字段过滤,提升响应效率。",
    parameters: z.object({
      username: z.string().describe("用户名"),
      fields: createFieldsSchema(),
    }),
  • The tool is included in the fastmcpTools array used for registration with FastMCP servers.
    const fastmcpTools = [
      GitlabAcceptMRTool,
      GitlabCreateMRCommentTool,
      GitlabCreateMRTool,
      GitlabGetUserTasksTool,
      GitlabRawApiTool,
      GitlabSearchProjectDetailsTool,
      GitlabSearchUserProjectsTool,
      GitlabUpdateMRTool,
    ];
  • Mapping from the tool's original name to the standardized GitLabToolName used in filtering and type definitions.
    const toolNameMapping = {
      [GitlabSearchUserProjectsTool.name]: "Gitlab_Search_User_Projects_Tool",
      [GitlabGetUserTasksTool.name]: "Gitlab_Get_User_Tasks_Tool",
      [GitlabSearchProjectDetailsTool.name]: "Gitlab_Search_Project_Details_Tool",
      [GitlabCreateMRTool.name]: "Gitlab_Create_MR_Tool",
      [GitlabUpdateMRTool.name]: "Gitlab_Update_MR_Tool",
      [GitlabAcceptMRTool.name]: "Gitlab_Accept_MR_Tool",
      [GitlabCreateMRCommentTool.name]: "Gitlab_Create_MR_Comment_Tool",
      [GitlabRawApiTool.name]: "Gitlab_Raw_API_Tool",
    } as const;
  • Import of the tool definition for use in registration.
    import { GitlabSearchUserProjectsTool } from "./tools/GitlabSearchUserProjectsTool";
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions field filtering for efficiency but doesn't cover critical aspects: whether this is a read-only operation (implied by '搜索' but not explicit), authentication requirements, rate limits, error handling, or what '活跃项目' (active projects) means. For a search tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise with two sentences: one stating the purpose and one about field filtering. It's front-loaded with the main function. However, the second sentence ('支持字段过滤,提升响应效率') could be integrated more smoothly, and there's room to add usage context without losing efficiency.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (search tool with user and project data), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what '用户信息及其活跃项目' includes (e.g., specific fields or project criteria), how results are structured, or any limitations. For a tool that likely returns rich data, this leaves the agent with insufficient context to use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so the schema already documents both parameters ('username' and 'fields') thoroughly. The description adds minimal value beyond the schema: it reiterates field filtering ('支持字段过滤') but doesn't provide additional context like examples beyond the schema's or explain how '活跃项目' relates to parameters. With high schema coverage, the baseline is 3, and the description doesn't significantly enhance parameter understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: '根据用户名搜索用户信息及其活跃项目' (search for user information and their active projects by username). It specifies the verb ('搜索' - search) and resource ('用户信息及其活跃项目' - user information and active projects). However, it doesn't explicitly differentiate from sibling tools like 'Gitlab Search Project Details Tool' or 'Gitlab Get User Tasks Tool', which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It mentions '支持字段过滤,提升响应效率' (supports field filtering to improve response efficiency), which is a feature but not usage context. There's no mention of when to choose this over 'Gitlab Get User Tasks Tool' or 'Gitlab Search Project Details Tool', nor any prerequisites or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ZephyrDeng/mcp-server-gitlab'

If you have feedback or need assistance with the MCP directory API, please join our Discord server